<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>员工管理系统</title>
    <script src="../js/vue.min.js"></script>
</head>
<body>
<div>
    <h1>员工管理系统</h1>
    <div v-if="isLogin">
        <!--href为空时跳转到当前页面-->
        <a href="javascript:void(0)">注册</a>
        <a href="javascript:void(0)" @click="login()">登录</a>
    </div>
    <div v-else>
        <input type="text" placeholder="请输入人员姓名" v-model="name">
        <input type="button" value="添加员工" @click="f()">
        <a href="javascript:void(0)" @click="logout()">退出登录</a>
    </div>
    <table border="1">
        <tr>
            <th>编号</th>
            <th>名字</th>
            <th v-else>操作</th>
        </tr>
        <tr v-for="(name ,i) in arr">
            <td>{{i+1}}</td>
            <td>{{name}}</td>
            <td v-else><input type="button" value="删除" @click="del(i)"></td>
        </tr>
    </table>
</div>
<script>
    let v= new Vue({
        el:"body>div",
        data:{
            isLogin:true,
            arr:["刘备","关羽","张飞"],
            name:""
        },
        methods:{
            login(){
                v.isLogin=false;
            },
            logout(){
                v.isLogin=true;
            },
            f(){
                v.arr.push(v.name)
            },
            del(i){
                v.arr.splice(i,1)
            }
        }
    })
</script>
</body>
</html>